﻿using System;
using System.Text;

namespace SharpDepend.WP8
{
    class EnviromentStatisticsManager : IEnviromentStatisticsManager
    {
        class EnviromentStatisticsClass : IEnviromentStatistics
        {
            private StringBuilder mSB = new StringBuilder();

            public long AppMemoryUsed
            {
                get
                {
                    return Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage;
                }
            }

            public long TotalMemory
            {
                get
                {
                    return Microsoft.Phone.Info.DeviceStatus.ApplicationMemoryUsageLimit;
                }
            }

            public int CPUSpeed
            {
                get
                {
                    return -1;
                }
            }

            public int CPUProcessors
            {
                get
                {
                    return Environment.ProcessorCount;
                }
            }

            public string Device
            {
                get
                {
                    return Microsoft.Phone.Info.DeviceStatus.DeviceName;
                }
            }

            public double ScaleFactor
            {
                get
                {
                    return System.Windows.Application.Current.Host.Content.ScaleFactor * 0.01f;
                }
            }
        }

        private static EnviromentStatisticsClass mInstance;

        public IEnviromentStatistics EnviromentStatistics
        {
            get
            {
                if (mInstance == null)
                {
                    mInstance = new EnviromentStatisticsClass();
                }

                return mInstance;
            }
        }
    }
}
